package com.yakumosakura.yakumoblade.registry.slashblade;

import com.yakumosakura.yakumoblade.item.TouHouMaid;
import com.yakumosakura.yakumoblade.item.YakumBladeSlashItem;
import com.yakumosakura.yakumoblade.registry.YakumoBladeItemTier;
import mods.flammpfeil.slashblade.SlashBladeCreativeGroup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent;

import java.util.function.Supplier;

import static com.yakumosakura.yakumoblade.Yakumoblade.MODID;

@Mod.EventBusSubscriber
public class YAItem {

    public static final DeferredRegister<Item> ITEMS;
    public static final ResourceLocation SlashBladeOfYakumoBlade=new ResourceLocation(MODID, "slashblade") ;
    public final   static YakumoBladeItemTier ya(Supplier repairIngredient){
        return new YakumoBladeItemTier(1,200,0,0,30,repairIngredient);
    }
    public static void register(RegisterEvent event) {
        event.register(ForgeRegistries.Keys.ITEMS, helper ->
                helper.register(SlashBladeOfYakumoBlade,
            new YakumBladeSlashItem(
                    ya(()->ForgeRegistries.ITEMS.getValue(SlashBladeOfYakumoBlade)),
                    25,
                    -2.4F,
                    new Item.Properties())
            )
        );

    }
    @SubscribeEvent
    public static void addCreative(BuildCreativeModeTabContentsEvent event) {
        if (event.getTabKey() == SlashBladeCreativeGroup.SLASHBLADE_GROUP.getKey()) {
            event.accept(ForgeRegistries.ITEMS.getValue(SlashBladeOfYakumoBlade));
        }
    }

    public static Item getItem(ResourceLocation item) {
        return BuiltInRegistries.ITEM.get(item);
    }

    static {
        ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
    }
}
